package com.kingdee.eas.custom.hr.affair.template.app;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.eas.base.attachment.common.AttachmentManagerFactory;
import com.kingdee.eas.base.attachment.common.AttachmentServerManager;
import com.kingdee.eas.base.attachment.common.SimpleAttachmentInfo;
import com.kingdee.eas.common.EASBizException;

public class TemplateMgrControllerBean extends AbstractTemplateMgrControllerBean {
	private static Logger logger = Logger
			.getLogger("com.kingdee.eas.custom.hr.affair.template.app.TemplateMgrControllerBean");

	@Override
	protected IObjectPK _saveAttachment(Context ctx, String[] attachmentIds, SimpleAttachmentInfo attachementInfo,
			IObjectValue editdata) throws BOSException, EASBizException {
		IObjectPK templateId = super._submit(ctx, editdata);

		if (attachementInfo != null) {
			AttachmentServerManager asm = AttachmentManagerFactory.getServerManager(ctx);
			if ((attachmentIds != null) && (attachmentIds.length > 0)) {
				asm.deleteAttachemtsByBoID(templateId.toString());
			}
			asm.addNewAttachment(templateId.toString(), attachementInfo);
		}
		return templateId;
	}
}